package clearsyntax.collection;

import static java.util.Collections.unmodifiableList;
import static java.util.Collections.unmodifiableMap;
import static java.util.Collections.unmodifiableSet;
import static java.util.Collections.unmodifiableSortedMap;
import static java.util.Collections.unmodifiableSortedSet;

import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.SortedMap;
import java.util.SortedSet;

import clearsyntax.types.Tuple2;

public final class immutable {

	public static <T> List<T> List(T... elems) {
		return (elems.length == 0) ? Collections.<T>emptyList() : unmodifiableList(mutable.List(elems));
	}

	public static <T> Set<T> Set(T... elems) {
		return (elems.length == 0) ? Collections.<T>emptySet() : unmodifiableSet(mutable.Set(elems));
	}

	public static <T> SortedSet<T> SortedSet(T... elems) {
		return (elems.length == 0) ? Util.<T>emptySortedSet() : unmodifiableSortedSet(mutable.SortedSet(elems));
	}

	public static <K, V> Map<K, V> Map(Tuple2<K, V>... entries) {
		return (entries.length == 0) ? Collections.<K, V>emptyMap() : unmodifiableMap(mutable.Map(entries));
	}

	public static <K, V> SortedMap<K, V> SortedMap(Tuple2<K, V>... entries) {
		return (entries.length == 0) ? Util.<K, V>emptySortedMap() : unmodifiableSortedMap(mutable.SortedMap(entries));
	}

}
